package com.boarsoft.boar.gateway.demo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.boarsoft.flow.core.bean.ProcessHandler;
import com.boarsoft.message.bean.Message;
import com.boarsoft.message.core.MessageService;

@Component("messageServiceProxy")
public class MessageServiceProxy implements ProcessHandler {
	private static final Logger log = LoggerFactory.getLogger(MessageServiceProxy.class);

	/** target queue name */
	protected String target;
	/** XxxMQClientEx */
	protected MessageService messageService;

	@Override
	public Object process(String entry, Object data, Throwable throwable) throws Throwable {
		// TODO 取出 POD ID
		Message m = new Message();
		try {
			m.setTarget(target);
			m.setTag("test"); // POD ID
			// ....
			messageService.put(m);
		} catch (Exception e) {
			log.error("Error on send message {}", m);
		}
		return null;
	}

	public String getTarget() {
		return target;
	}

	public void setTarget(String target) {
		this.target = target;
	}

	public MessageService getMessageService() {
		return messageService;
	}

	public void setMessageService(MessageService messageService) {
		this.messageService = messageService;
	}

}
